#!/bin/bash
# PowerTrace预ProcessExampleScript

echo "====================================="
echo "  PowerTrace预ProcessExample"
echo "====================================="

INPUT_FILE="traces_highfreq.npz"

if [ ! -f "$INPUT_FILE" ]; then
    echo "Error: 未找ToInput file $INPUT_FILE"
    echo "请先Run collect_traces.py 采集Data"
    exit 1
fi

# Example1: Basic预Process
echo -e "\n[Example1] Basic预Process（Alignment+Filtering+Normalization）"
python3 preprocess_traces.py "$INPUT_FILE" \
    -o traces_basic.npz \
    --show-stats

# Example2: 高质量预Process（推荐用于CPAAttack）
echo -e "\n[Example2] 高质量预Process（Denoising+OutlierRemove）"
python3 preprocess_traces.py "$INPUT_FILE" \
    -o traces_hq.npz \
    --denoise --denoise-method moving_average \
    --remove-outliers --outlier-threshold 3.0 \
    --filter-cutoff 0.15 \
    --norm-method robust \
    --show-stats

# Example3: 降维Process（用于大Data集）
echo -e "\n[Example3] 降维Process（重Sampling+池化）"
python3 preprocess_traces.py "$INPUT_FILE" \
    -o traces_reduced.npz \
    --resample 0.5 \
    --pooling average --pooling-size 2 \
    --show-stats

# Example4: 时间窗口Extract
echo -e "\n[Example4] Extract时间窗口（100-500Sampling点）"
python3 preprocess_traces.py "$INPUT_FILE" \
    -o traces_window.npz \
    --window 100:500 \
    --denoise \
    --show-stats

# Example5: 极致Denoising（用于低SNRData）
echo -e "\n[Example5] 极致Denoising"
python3 preprocess_traces.py "$INPUT_FILE" \
    -o traces_denoised.npz \
    --denoise --denoise-method moving_average --moving-window 7 \
    --filter-type lowpass --filter-cutoff 0.08 --filter-order 6 \
    --norm-method robust \
    --show-stats

echo -e "\n====================================="
echo "  AllExampleCompleted！"
echo "====================================="
echo "Generate的File："
ls -lh traces_*.npz | tail -5
